
import java.util.Scanner;

class PAR {

    public static void main(String[] args) {
        Scanner entrada = new Scanner(System.in);
        String J1;
        String J2;
        int A, B;
        int cont = 1;
        int N = entrada.nextInt();
        while (N != 0) {
            String[] V = new String[N];
            J1 = entrada.next();
            J2 = entrada.next();
            for (int i = 0; i < N; i++) {
                A = entrada.nextInt();
                B = entrada.nextInt();

                if ((A + B) % 2 == 0) {
                    V[i] = J1;
                } else {
                    V[i] = J2;
                }
            }
            System.out.println("Teste " + cont);
            for (int i = 0; i < N; i++) {
                System.out.println(V[i]);
            }
            System.out.println();
            N = entrada.nextInt();
            cont++;
        }
    }
}
